<?php

namespace app\rental\controller;

use cmf\controller\HomeBaseController;
use app\rental\model\RentalCategoryModel;

class SearchController extends HomeBaseController
{
    public function index()
    {
        $keyword = $this->request->param('keyword');
        $categoryId = $this->request->param('category_id', 0, 'intval');
        $rentalCategoryModel = new RentalCategoryModel();
        $this->assign("rental_category", $rentalCategoryModel->getRentalCategory());
        if (empty($keyword)) {
            $this -> error("关键词不能为空！请重新输入！");
        }
        $this -> assign("category_id", $categoryId);
        $this -> assign("keyword", $keyword);
        return $this->fetch('/search');
    }
}
